package com.learn.jackson.annotation.jsonInclude;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.FieldDefaults;

import java.util.List;

/**
 * @author XuYang
 * @since 2025/6/9 9:53
 */
@Data
@NoArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
@AllArgsConstructor(staticName = "of")
public class JsonIncludeEntity2 {
    @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = CustomFilter.class)
    List<Integer> list;

    public static class CustomFilter {
        /**
         * true ： 不序列化该字段
         */
        @Override
        public boolean equals(Object obj) {
            if (obj instanceof List list) {
                return list.contains(1);
            }
            return true;
        }
    }
}
